package com.seeyon.apps.commonExt.domain;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.hutool.core.map.MapUtil;

/**
 * @description:
 * @author: huangjin
 * @time: 2025/4/1 16:38
 */
public class Cap4Update {

    private Map<String, Object> values = new HashMap<>();

    public Cap4Update add(String key, Object value) {
        this.values.put(key, value);
        return this;
    }

    public String build() {
        if (MapUtil.isEmpty(values)) {
            return "";
        }
        List<String> collect = new ArrayList<>();
        for (Map.Entry<String, Object> entry : values.entrySet()) {
            if (entry.getValue() instanceof String) {
                collect.add(entry.getKey() + "= '" + entry.getValue() + "'");
            }else {
                collect.add(entry.getKey() + "=" + entry.getValue());
            }

        }
        return String.format(" %s ", String.join(",", collect));
    }
}
